﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using log4net;
using Topshelf;
using ConsoleApplication1._03_Service;

namespace ConsoleApplication1
{
    class Program
    {
        private static ILog _logger = LogManager.GetLogger(typeof(Program));

        static void Main(string[] args)
        {
            try
            {
                HostFactory.Run(x =>
                {
                    x.Service<MainService>(y =>
                    {
                        y.ConstructUsing(name => new MainService());
                        y.WhenStarted(tc => tc.Start());
                        y.WhenStopped(tc => tc.Stop());
                    });
                    x.RunAsLocalSystem();
                    x.SetDescription("满堂创品记账本服务");
                    x.SetDisplayName("Man Tang Chuang Pin Accounting Service");
                    x.SetServiceName("MTCPService");
                });
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex);
            }
        }
    }
}
